<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>白卡出入库统计</title>

<script type="text/javascript" src="../script/common.js"></script>
<script language="javascript" src="../script/common_stat.js"></script>
<script type="text/javascript" src="../script/print.js"></script>
<script type="text/javascript" src="../script/pivot.js"></script>
<script type="text/javascript" src="../script/crosstab.js"></script>

<script type="text/javascript">
	var crosstab = new Crosstab();
	
	var statForm;
	var Page = {} ;
	var pivot;
	function load(){
		Eui.showNavigation();
		setPages(["queryView","newPivot"]);
		
		statForm = $("statForm");
		
		//初始化卡片类型(查询form)
		Common.initDict(statForm.cardType,"blankcard_type","全 部");
		
		CardStore.initCardStoreStat("stat_btn")
		newPivot()
	}
	
	//选择卡片规格
	function selCardSpec(){
		CardStore.selCardSpec(setCardSpec,{type:statForm.cardType.value})
	}
	
	function setCardSpec(v){
		statForm.cardSpec.value = v.name;
	}
	
	function clearCardSpec(){
		statForm.cardSpec.value="";
	}
	function newPivot(){
		var sql = "blank_card_stock_stat";
		var crossconf = {};
		crossconf.measures = {"startAmount":"期初库存","endAmount":"期末库存","deliveryCount":"出库次数","deliveryAmount":"出库数量","warehousingCount":"入库次数","warehousingAmount":"入库数量","adjustCount":"调整次数","adjustAmount":"调整数量"}
		crossconf.defaultMeasure = {startAmount:true,warehousingCount:true,warehousingAmount:true,deliveryCount:true,deliveryAmount:true,adjustCount:true,adjustAmount:true,endAmount:true};
		crossconf.dimensions = {"blankCardType":"","cardSpec":{name:"卡片规格",option:{factory:"厂商",name:"名称"}}}
		crossconf.defaultVertical = {};
		crossconf.defaultHorizon = {blankCardType:true,cardSpec:{factory:true,name:true}};
		pivot = new Pivot('newPivot',sql,null,{disableConf:true,initPivotHead:initPivotHead});
		//pivot.ShowZero = true;
		pivot.initConf(crossconf);
		pivot.setPivotHead('pivotTitle','白卡出入库统计');
	}
	function initPivotHead(div){
		var title = '<table width="100%" border="0" cellspacing="0" cellpadding="5" style="width:600">'
				  + '<tr><td align="center" class="reportTitle" height="50" colspan="3" id="#DIVID#_pivotTitle"></td></tr>'
				  + '<tr><td width="32%">统 计 人：<span id="#DIVID#_statOper"></span></td><td width="35%">统计机构：<span id="#DIVID#_statOrg"></span></td><td>统计时间：<span id="#DIVID#_statTime"></span></td></tr>'
				  + '<tr><td>卡片规格：<span id="#DIVID#_cardSpec"></span></td><td>起始时间：<span id="#DIVID#_beginDate"></span></td><td>结束时间：<span id="#DIVID#_endDate"></span></td></tr>'
				  + '<tr><td>卡片类型：<span id="#DIVID#_cardType"></span></td></tr></table>';
		$(div+'_pivot_head').innerHTML = title.replace(/#DIVID#/g,div);
	}
	function doQuery(){
		CardStore.formatStatDate()
		if(!checkForm(statForm))return;
		pivot.param = Common.getValues(statForm);
		
		pivot.setPivotHead('statTime',Format.today(true));
		pivot.setPivotHead('statOper',Common.cOperator().name);
		pivot.setPivotHead('statOrg',Common.cOrg().name);
		pivot.setPivotHead('cardSpec',pivot.param.cardSpec?pivot.param.cardSpec:"全部");
		pivot.setPivotHead('cardType',pivot.param.cardType?Common.getText("blankcard_type",pivot.param.cardType):"全部");
		pivot.setPivotHead('beginDate',pivot.param.beginDate);
		pivot.setPivotHead('endDate',pivot.param.endDate);

		pivot.refresh();
		switchPage('newPivot');
	}
</script>
</head>

<body onload="load()">
	<div class="nav"><div id="nav">&nbsp;</div></div>
	<div id="queryView" class="form">
		<div class="formTitle">白卡出入库统计：查询条件</div>
		<form id="statForm" name="statForm">
			<input type="hidden" name="cardSpecId"/>
			<table cellSpacing=0 cellPadding=4 width="100%" border=0 class="col3 label4">
				<tr>
					<td><label>白卡类型</label> <select name="cardType" onchange="clearCardSpec()"><option></option></select></td>
				</tr>
				<tr>
					<td><label>卡片规格</label> <input type="text"  name="cardSpec"><a class="orga" href="javascript:void(0)" onclick="selCardSpec()" >&nbsp;&nbsp;</a></td>
				</tr>
				
			</table>
			
			<div id="stat_btn"></div>
		</form>
	</div>
	<!-- Flash 报表-->
	<div id="newPivot" style="display:none;"></div>
</body>

</html>
